﻿using DSPL.Contracts.ViewModel;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DSPL.Contracts;

namespace DSPL.Finac.ViewModel
{
    public class SalesRepTestModel : BaseViewModel
    {
        public SalesRepTestModel()
            : base()
        {
            MessageTitle = "Sales Rep Mater File";
        }

        private bool isSalRepCodeFocused;

        public bool IsSalRepCodeFocused
        {
            get { return isSalRepCodeFocused; }
            set
            {
                isSalRepCodeFocused = value;
                OnPropertyChanged("IsSalRepCodeFocused");
            }
        }

        private bool isLocationFocused;

        public bool IsLocationFocused
        {
            get { return isLocationFocused; }
            set { isLocationFocused = value;
            OnPropertyChanged("IsLocationFocused");
            }
        }
        

        protected override void PreDataValidateExecuted(object obj)
        {
            base.PreDataValidateExecuted(obj);
            isSalRepCodeFocused = true;

            if (string.IsNullOrEmpty(CurrentRow["RepCode"].ToString()))
            {
                MessageService.ShowMessage(MessageText.RepCodeNotEmpty, MessageTitle, MessageType.InfoOK);
                IsSalRepCodeFocused = true;
                this.IsValid = false;
                return;
            }

            if (string.IsNullOrEmpty(CurrentRow["LocPk"].ToString()))
            {
                MessageService.ShowMessage(MessageText.LocationNotEmpty, MessageTitle, MessageType.InfoOK);
                IsLocationFocused = true;
                this.IsValid = false;
                return;
            }

            this.IsValid = true;
        }
        
    }
}
